package com.qf.fmall2202.product.controller;

import com.qf.fmall2202.product.service.ProductCommentsService;
import com.qf.fmall2202.product.service.ProductParamsService;
import com.qf.fmall2202.product.service.ProductService;
import com.qf.fmall2202.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商品 商品信息相关表：分类表，商品图片表，商品规格表，商品参数表 前端控制器
 * </p>
 *
 * @author 徐英海
 * @since 2022-11-07
 */
@CrossOrigin
@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private ProductService productService;
    @Autowired
    private ProductParamsService productParamsService;
    @Autowired
    private ProductCommentsService productCommentsService;

    @GetMapping("/detail-info/{productId}")
    public ResultVo detailInfo(@PathVariable("productId") String productId) {
        return productService.queryDetailInfo(productId);
    }

    @GetMapping("/detail-params/{productId}")
    public ResultVo detailParams(@PathVariable("productId") String productId) {
        return productParamsService.queryDetailParams(productId);
    }

    @GetMapping("/detail-commontscount/{productId}")
    public ResultVo detailCommontscount(@PathVariable("productId") String productId) {
        return productCommentsService.queryProductCommentsService(productId);
    }

    @GetMapping("/detail-commonts/{productId}")
    public ResultVo detailCommonts(@PathVariable("productId") String productId, Integer pageNum, Integer limit) {
        return productCommentsService.queryDetailCommonts(productId, pageNum, limit);
    }
}
